package com.example.demo.config;

import com.example.demo.filter.TokenFilter;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<TokenFilter> filterOneRegister() {
        FilterRegistrationBean<TokenFilter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new TokenFilter());

        //设置过滤路径
        filterRegistrationBean.addUrlPatterns("/user/logout");
        filterRegistrationBean.addUrlPatterns("/user/test");
        filterRegistrationBean.addUrlPatterns("/user/getMessage");
        filterRegistrationBean.addUrlPatterns("/user/recharge");
        filterRegistrationBean.addUrlPatterns("/user/borrowBook");
        filterRegistrationBean.addUrlPatterns("/user/modifyPassword");
        filterRegistrationBean.addUrlPatterns("/user/returnBook");
        filterRegistrationBean.addUrlPatterns("/user/getCostRecord");



        filterRegistrationBean.addUrlPatterns("/record/getRecord");
        filterRegistrationBean.addUrlPatterns("/record/getRecordByName");



        //设置优先级
		filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }
}
